package base

import "strings"

type BigTabCol struct {
	Name        string   `yaml:"name"`
	Desc        string   `yaml:"desc"`
	DfTables    []string `yaml:"dfTables"`
	MfTables    []string `yaml:"mfTables"`
	DtidCol     string   `yaml:"dtidCol"`
	AcblCol     string   `yaml:"acblCol"`
	Where       string   `yaml:"where"`
	Children    []string `yaml:"children"`
	GroupBy     string   `yaml:"groupBy"`
	BaseColName string   `yaml:"baseColName"`
	BaseWhere   string   `yaml:"baseWhere"`
	DiviTable   string   `yaml:"diviTable"`
}

var bigTabCols []BigTabCol

func GetBigTabCol(name string) (col *BigTabCol) {
	for i := 0; i < len(bigTabCols); i++ {
		if bigTabCols[i].Name == name {
			return &bigTabCols[i]
		}
	}
	return nil
}
func GetBigTabColPieItems() (pieItems map[string][]string) {
	pieItems = make(map[string][]string)
	for i := 0; i < len(bigTabCols); i++ {
		items := make([]string, 0, 4)
		if len(bigTabCols[i].Children) > 0 || bigTabCols[i].GroupBy != "" {
			items = append(items, "TPNO")
		}
		name := bigTabCols[i].Name
		if !strings.HasPrefix(name, "ZS_") && !strings.HasPrefix(name, "SALE_") {
			items = append(items, "PERD")
		}
		if !strings.HasPrefix(name, "SALE_") {
			items = append(items, "ITID")
		}
		items = append(items, "CYNO")
		pieItems[name] = items
	}
	return
}
